package cn.exrick.xboot.base.entity

import cn.exrick.xboot.core.base.XbootBaseEntityKt
import cn.exrick.xboot.core.common.constant.CommonConstant
import cn.exrick.xboot.core.common.utils.SnowFlakeUtil
import com.baomidou.mybatisplus.annotation.TableId
import com.baomidou.mybatisplus.annotation.TableName
import io.swagger.annotations.ApiModel
import io.swagger.annotations.ApiModelProperty
import java.math.BigDecimal
import javax.persistence.Column
import javax.persistence.Entity
import javax.persistence.Id
import javax.persistence.Table
import javax.validation.constraints.NotNull

/**
 * @author Fei
 */
@Entity
@Table(name = "base_area")
@TableName("base_area")
@ApiModel(value = "区域管理")
data class Area(

        @ApiModelProperty(value = "区域名称")
        var title: @NotNull(message = "区域名称不能为空") String? = null,

        @ApiModelProperty(value = "父id")
        var parentId: String? = null,

        @ApiModelProperty(value = "是否为父节点(含子节点) 默认false")
        var isParent:Boolean? = false,

        @ApiModelProperty(value = "排序值")
        @Column(precision = 10, scale = 2)
        var sortOrder: BigDecimal? = null,

        @ApiModelProperty(value = "是否启用 0启用 -1禁用")
        var status:Int? = CommonConstant.STATUS_NORMAL,

        @ApiModelProperty(value = "父节点名称")
        var parentTitle: String? = null,

        @ApiModelProperty("区域等级", hidden = true)
        var areaLevel: Int? = null

) : XbootBaseEntityKt() {

    @Id
    @TableId
    override var id: String = SnowFlakeUtil.nextId().toString()


    companion object {
        const val serialVersionUID = 1L
    }
}